package com.zhiwang.xiaoqu.ui

import android.os.Bundle
import com.zhiwang.xiaoqu.R
import com.zhiwang.xiaoqu.ktextension.setImmersive
import com.zhiwang.xiaoqu.mvp.model.Store
import com.zhiwang.xiaoqu.mvp.model.sharepref.PrefManager
import com.zhiwang.xiaoqu.widget.SimpleDialog
import kotlinx.android.synthetic.main.activity_account_setting.*
import quickStartActivity
import suicideAfterTransition

class AccountSettingActivity : BaseActivity() {

    var simpleDialog: SimpleDialog? = null

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        window.setImmersive()
        setContentView(R.layout.activity_account_setting)

        init()
    }

    private fun init() {

        tv_exit.setOnClickListener {
            exitWithRedPacket()
        }
    }


    private fun exitWithRedPacket() {
        simpleDialog = SimpleDialog.Builder(this)
            .poster(R.drawable.tchb_bg)
            .descText("今日签到红包未领取，确认退出？")
            .descTextSizeSp(15f)
            .positiveButton("去签到", 16f, R.drawable.btn_w230, R.color.colorWhite1)
            .onPositiveButtonClick {
                //some op
                WebViewActivity.load(
                    this@AccountSettingActivity,
                    Store.URL_RED_PACKET,
                    needTitle = false,
                    transparent = true
                )
                simpleDialog?.dismiss()

            }
            .negativeButton("关闭", 16f, R.drawable.btn_w230_gray, R.color.colorGray4)
            .onNegativeButtonClick {

                simpleDialog?.dismiss()
                PrefManager.clearToken()
                quickStartActivity(PhoneLoginActivity::class.java)
                suicideAfterTransition()
            }
            .create()

        simpleDialog?.show()
    }

    private fun exitWithTasks() {
        simpleDialog = SimpleDialog.Builder(this)
            .descText("还有海量赚钱任务，确认退出？")
            .descTextSizeSp(15f)
            .negativeButton("取消", 16f, R.drawable.btn_w230, R.color.colorWhite1)
            .onNegativeButtonClick {
                simpleDialog?.dismiss()
            }
            .positiveButton("确定", 16f, R.drawable.btn_w230_gray, R.color.colorGray4)
            .onPositiveButtonClick {

                //some op
//                LoginActivity.start(this)
                quickStartActivity(PhoneLoginActivity::class.java)
                suicideAfterTransition()
            }
            .create()

        simpleDialog?.show()
    }
}
